home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / totsrc.zip / TOTWIN.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-11  |  36KB  |  1,274 lines

  1. {               Copyright 1991 TechnoJock Software, Inc.               }
  2. {                          All Rights Reserved                         }
  3. {                         Restricted by License                        }
  4.  
  5. {                             Build # 1.00                             }
  6.  
  7. Unit totWIN;
  8. {$I TOTFLAGS.INC}
  9.  
  10. {
  11.  Development Notes:
  12.                 600 = Close Window
  13.                 601 = Moved
  14.                 602 = Resized
  15.                 610 = Scroll Up One
  16.                 611 = Scroll Down One
  17.                 612 = Scroll Left one
  18.                 613 = Scroll Right one
  19.                 614 = Vertical Scroll Bar
  20.                 615 = Horizontal Scroll Bar
  21. }
  22.  
  23. INTERFACE
  24.  
  25. uses DOS, CRT, totSYS, totLOOK, totINPUT, totFAST, totMISC;
  26.  
  27. TYPE
  28.  
  29. WinPtr = ^WinOBJ;
  30. pWinOBJ = ^WinOBJ;
  31. WinOBJ = object
  32.    vBorder: tCoords;
  33.    vOuter: tCoords;
  34.    vClose: boolean;            {is close icon active}
  35.    vUnderneathPtr: pointer;    {ptr to saved screen}
  36.    vSavedSize: longint;        {amount of memory saved}
  37.    vTitle: string;             {window title}
  38.    vBorderAttr: byte;          {border attribute}
  39.    vTitleAttr: byte;           {title attribute}
  40.    vBodyAttr: byte;            {main text attribute}
  41.    vIconsAttr: byte;           {close and zoom icon attribute}
  42.    vStyle: byte;               {border style}
  43.    vRemove: boolean;           {remove the window when done}
  44.    vCursX: byte;               {saved cursor location}
  45.    vCursY: byte;               {saved       -"-      }
  46.    vCursTop: byte;             {saved cursor size}
  47.    vCursBot: byte;             {saved     -"-    }
  48.    vOldWin: tByteCoords;       {previous window coords}
  49.    vOldWinConfine: boolean;    {were window coords active}
  50.    vMVisible: boolean;         {was mouse visible}
  51.    vFillWin: boolean;          {clear window core when redrawn}
  52.    {methods...}
  53.    constructor Init;
  54.    procedure   SetSize(X1,Y1,X2,Y2,Style:byte);
  55.    procedure   SetTitle(Title:string);
  56.    procedure   SetColors(Border,Body,Title,Icons: byte);
  57.    procedure   SetRemove(On:boolean);
  58.    procedure   SetClose(On:boolean);
  59.    procedure   SetWindow;
  60.    procedure   GetSize(var X1,Y1,X2,Y2,Style:byte);
  61.    function    GetX:byte;
  62.    function    GetY:byte;
  63.    function    GetStyle: byte;
  64.    function    GetBorderAttr: byte;
  65.    function    GetTitleAttr: byte;
  66.    function    GetBodyAttr: byte;
  67.    function    GetIconsAttr: byte;
  68.    function    GetRemoveStatus: boolean;
  69.    procedure   Save;
  70.    procedure   PartSave(X1,Y1,X2,Y2:byte; var Dest);
  71.    procedure   PartRestore(X1,Y1,X2,Y2:byte; var Source);
  72.    procedure   ComputeSavedCoords;
  73.    procedure   DrawCore;
  74.    procedure   GrowDraw;
  75.    procedure   Remove;
  76.    procedure   WinGetKey(var K:word;var X,Y:byte);
  77.    procedure   SetBoundary(X1,Y1,X2,Y2:byte);                  VIRTUAL;
  78.    procedure   WinKey(var K:word;var X,Y:byte);                VIRTUAL;
  79.    procedure   Draw;                                           VIRTUAL;
  80.    destructor  Done;                                           VIRTUAL;
  81. end; {WinOBJ}
  82.  
  83. MoveWinPtr = ^MoveWinOBJ;
  84. pMoveWinOBJ = ^MoveWinOBJ;
  85. MoveWinOBJ = object (WinOBJ)
  86.    vBoundary: tCoords;       {max area in which window can move}
  87.    vMoveKey: word;
  88.    vAllowMove: boolean;
  89.    {methods...}
  90.    constructor Init;
  91.    procedure   SetMoveKey(K:word);
  92.    procedure   SetAllowMove(On:boolean);
  93.    procedure   BuildBackground(var BackScr: ScreenOBJ);
  94.    procedure   RemoveShadow(var OriginalScreen: ScreenOBJ);
  95.    procedure   RefreshUnderneath(BackScr: ScreenOBJ);
  96.    procedure   WMove(UsingMouse:boolean;OldX,OldY:byte);
  97.    procedure   WinKey(var K:word;var X,Y:byte);                VIRTUAL;
  98.    procedure   SetBoundary(X1,Y1,X2,Y2:byte);                  VIRTUAL;
  99.    destructor  Done;                                           VIRTUAL;
  100. end; {MoveWinOBJ}
  101.  
  102. pScrollWinOBJ = ^ScrollWinOBJ;
  103. ScrollWinOBJ = object (MoveWinOBJ)
  104.    vScrollV: boolean;       {show vertical scroll bar}
  105.    vScrollH: boolean;       {show horizontal scroll bar}
  106.    {methods ...}
  107.    constructor Init;
  108.    procedure   SetScrollable(Vert,Horiz:boolean);
  109.    procedure   DrawHorizBar(Current,Max: longint);
  110.    procedure   DrawVertBar(Current,Max: longint);
  111.    procedure   Winkey(var K:word;var X,Y:byte);                VIRTUAL;
  112.    procedure   Draw;                                           VIRTUAL;
  113.    destructor  Done;                                           VIRTUAL;
  114. end; {ScrollWinOBJ}
  115.  
  116. StretchWinPtr = ^StretchWinOBJ;
  117. pStretchWinOBJ = ^StretchWinOBJ;
  118. StretchWinOBJ = object (ScrollWinOBJ)
  119.    vZoomed: boolean;        {is window zoomed at present}
  120.    vPreZoom: tCoords;        {size of window in Unzoomed state}
  121.    vMinWidth: byte;         {min width of SmartWin}
  122.    vMinDepth: byte;         {min depth of SmartWin}
  123.    vStretchKey:word;        {keycode for manual stretch}
  124.    vZoomKey:word;           {keycode for zoom}
  125.    vAllowStretch: boolean;  {is user allowed to stretch}
  126.    vSmartStretch: boolean;  {refresh window during stretch}
  127.    {methods ...}
  128.    constructor Init;
  129.    procedure   SetMinSize(Width,depth:byte);
  130.    procedure   Stretch(UsingMouse:boolean;OldX,OldY:byte);
  131.    procedure   SetAllowStretch(On:boolean);
  132.    procedure   ToggleZoom;
  133.    procedure   Refresh;
  134.    procedure   StretchRefresh;                                 VIRTUAL;
  135.    procedure   Winkey(var K:word;var X,Y:byte);                VIRTUAL;
  136.    procedure   Draw;                                           VIRTUAL;
  137.    destructor  Done;                                           VIRTUAL;
  138. end; {StretchWinOBJ}
  139.  
  140. procedure WinInit;
  141.  
  142. IMPLEMENTATION
  143.  
  144. {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  145. {                                                               }
  146. {     U N I T   P R O C E D U R E S   &   F U N C T I O N S     }
  147. {                                                               }
  148. {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}
  149.  
  150. procedure Error(Err:byte);
  151. {routine to display error}
  152. const
  153.    Header = 'WinTOT error: ';
  154. var
  155.    Msg : string;
  156. begin
  157.    Case Err of
  158.    1: Msg := 'Not enough memory to create window';
  159.    2: Msg := 'Invalid window dimensions';
  160.    3: Msg := 'Not enough memory to create SmartWin';
  161.    else  Msg := 'Unknown Error';
  162.    end; {case}
  163.    Writeln(Header,Msg);
  164. {Maybe Add non-fatal compiler directive}
  165.    halt;
  166. end; {Error}
  167.  
  168. {||||||||||||||||||||||||||||||||||||}
  169. {                                    }
  170. {    W i n O B J   M E T H O D S     }
  171. {                                    }
  172. {||||||||||||||||||||||||||||||||||||}
  173.  
  174. constructor WinOBJ.Init;
  175. {}
  176. begin
  177.    SetSize(10,5,70,20,1);
  178.    SetTitle('');
  179.    SetRemove(true);
  180.    with LookTOT^ do
  181.        SetColors(WinBorder,WinBody,WinTitle,WinIcons);
  182.    vUnderneathPtr := Nil;
  183.    vMVisible := true;
  184.    vClose := true;
  185.    vFillWin := true;
  186. end; {of const WinOBJ.Init}
  187.  
  188. procedure WinOBJ.SetSize(X1,Y1,X2,Y2,Style:byte);
  189. {}
  190. begin
  191. {$IFDEF CHECK}
  192.    if (X2 < X1 + 2)
  193.    or (Y2 < Y1 + 2)
  194.    or (Y2 > Screen.Depth)
  195.    or (X2 > Screen.Width) then
  196.       Error(2);
  197. {$ENDIF}
  198.    vBorder.X1 := X1;
  199.    vBorder.Y1 := Y1;
  200.    vBorder.X2 := X2;
  201.    vBorder.Y2 := Y2;
  202.    vStyle := Style;
  203. end; {WinOBJ.SetSize}
  204.  
  205. procedure WinOBJ.GetSize(var X1,Y1,X2,Y2,Style:byte);
  206. {}
  207. begin
  208.    X1 := vBorder.X1;
  209.    Y1 := vBorder.Y1;
  210.    X2 := vBorder.X2;
  211.    Y2 := vBorder.Y2;
  212.    Style := vStyle;
  213. end; {WinOBJ.GetSize}
  214.  
  215. function WinOBJ.GetX:byte;
  216. {}
  217. begin
  218.    GetX := vBorder.X1;
  219. end; {WinOBJ.GetX}
  220.  
  221. function WinOBJ.GetY:byte;
  222. {}
  223. begin
  224.    GetY := vBorder.Y1;
  225. end; {WinOBJ.GetY}
  226.  
  227. function WinOBJ.GetStyle:byte;
  228. {}
  229. begin
  230.    GetStyle := vStyle;
  231. end; {WinOBJ.GetStyle}
  232.  
  233. function WinOBJ.GetBorderAttr: byte;
  234. {}
  235. begin
  236.    GetBorderAttr := vBorderAttr;
  237. end; {WinOBJ.GetBorderAttr}
  238.  
  239. function WinOBJ.GetTitleAttr: byte;
  240. {}
  241. begin
  242.    GetTitleAttr := vTitleAttr;
  243. end; {WinOBJ.GetTitleAttr}
  244.  
  245. function WinOBJ.GetBodyAttr: byte;
  246. {}
  247. begin
  248.    GetBodyAttr := vBodyAttr;
  249. end; {WinOBJ.GetBodyAttr}
  250.  
  251. function WinOBJ.GetIconsAttr: byte;
  252. {}
  253. begin
  254.    GetIconsAttr := vIconsAttr;
  255. end; {WinOBJ.GetIconsAttr}
  256.  
  257. procedure WinOBJ.SetRemove(On:boolean);
  258. {}
  259. begin
  260.    vRemove := On;
  261. end; {Window.SetRemove}
  262.  
  263. procedure WinOBJ.SetClose(On:boolean);
  264. {}
  265. begin
  266.    vClose := On;
  267. end; {WinOBJ.SetClose}
  268.  
  269. function WinOBJ.GetRemoveStatus: boolean;
  270. {}
  271. begin
  272.    GetRemoveStatus := vRemove;
  273. end; {WinOBJ.GetRemoveStatus}
  274.  
  275. procedure WinOBJ.SetTitle(Title:string);
  276. {}
  277. begin
  278.    vTitle := Title;
  279. end; {WinOBJ.SetTitle}
  280.  
  281. procedure WinOBJ.SetColors(Border,Body,Title,Icons: byte);
  282. {}
  283. begin
  284.    if Border <> 0 then
  285.       vBorderAttr := Border;
  286.    if Title <> 0 then
  287.       vTitleAttr := Title;
  288.    if Body <> 0 then
  289.       vBodyAttr := Body;
  290.    if Icons <> 0 then
  291.       vIconsAttr := Icons;
  292. end; {WinOBJ.SetColors}
  293.  
  294. procedure WinOBJ.SetBoundary(X1,Y1,X2,Y2:byte);
  295. {abstract}
  296. begin end;
  297.  
  298. procedure WinOBJ.ComputeSavedCoords;
  299. {checks shodow position and style and computes saved screen coords}
  300. begin
  301.    ShadowTOT^.OuterCoords(vBorder,vOuter);
  302. end; {WinOBJ.ComputeSavedCoords}
  303.  
  304. procedure WinOBJ.SetWindow;
  305. {}
  306. begin
  307.    with vBorder do
  308.    case vStyle of
  309.       0: Screen.SetWindow(X1,Y1,X2,Y2);
  310.       6: Screen.SetWindow(succ(X1),Y1+3,pred(X2),Y2);
  311.       else Screen.SetWindow(succ(X1),succ(y1),pred(X2),pred(Y2));
  312.    end; {case}
  313. end; {WinOBJ.SetWindow}
  314.  
  315. procedure WinOBJ.Save;
  316. {}
  317. var
  318.   MemoryNeeded: longint;
  319. begin
  320.    ComputeSavedCoords;
  321.    MemoryNeeded := succ(vOuter.X2-vOuter.X1)*succ(vOuter.Y2-vOuter.Y1)*2;
  322.    if MaxAvail < MemoryNeeded then
  323.       Error(1)
  324.    else
  325.    begin
  326.       if vUnderneathPtr <> nil then
  327.       begin
  328.          freemem(vUnderneathPtr,vSavedSize);
  329.          vUnderneathPtr := nil;
  330.       end;
  331.       getmem(vUnderneathPtr,MemoryNeeded);
  332.       PartSave(vOuter.X1,vOuter.Y1,vOuter.X2,vOuter.Y2,vUnderneathPtr^);
  333.       vSavedSize := MemoryNeeded;
  334.       vCursX := Screen.WhereX;
  335.       vCursY := Screen.WhereY;
  336.       Screen.CursSave;
  337.       vCursTop:= Screen.CursTop;
  338.       vCursBot:= Screen.CursBot;
  339.       Screen.WindowCoords(vOldWin);
  340.       vOldWinConfine := Screen.WindowActive;
  341.    end;
  342. end; {WinOBJ.Save}
  343.  
  344. procedure WinOBJ.DrawCore;
  345. {}
  346. begin
  347.    if (vStyle in [1..5]) and vClose then
  348.    begin
  349.       with vBorder do
  350.       begin
  351.          Screen.BoxEngine(X1,Y1,X2,Y2,4,4,vBorderAttr,vTitleAttr,vBodyAttr,
  352.                           vStyle,vFillWin,vTitle);
  353.          Screen.WriteAT(X1+2,Y1,vBorderAttr,'[ ]');
  354.          Screen.WriteAT(X1+3,Y1,vIconsAttr,'■');
  355.       end;
  356.    end
  357.    else
  358.       with vBorder do
  359.          Screen.BoxEngine(X1,Y1,X2,Y2,0,0,vBorderAttr,vTitleAttr,vBodyAttr,
  360.                           vStyle,vFillWin,vTitle);
  361.    if (vStyle = 6) and vClose then
  362.       with vBorder do
  363.          Screen.WriteAT(X1+3,Y1,vIconsAttr,'■');
  364. end; {WinOBJ.DrawCore}
  365.  
  366. procedure WinOBJ.Draw;
  367. {}
  368. var WasOn: boolean;
  369. begin
  370.    vMVisible := Mouse.Visible;
  371.    Save;
  372.    WasOn := Screen.WindowOff;
  373.    ShadowTOT^.DrawShadow(vBorder);
  374.    DrawCore;
  375.    SetWindow;
  376.    if not vMVisible then
  377.       Mouse.Show;
  378. end; {WinOBJ.Draw}
  379.  
  380. procedure WinOBJ.GrowDraw;
  381. {}
  382. var
  383.   I,TX1,TY1,TX2,TY2,Ratio : integer;
  384.   WasOn: boolean;
  385. begin
  386.    Save;
  387.    vMVisible := Mouse.Visible;
  388.    WasOn := Screen.WindowOff;
  389.    with vBorder do
  390.    begin
  391.       if 2*(Y2 -Y1 +1) > X2 - X1 + 1 then
  392.          Ratio :=   2
  393.       else
  394.          Ratio :=  1;
  395.       TX2 := (X2 - X1) div 2 + X1 + 2;
  396.       TX1 := TX2 - 3;                 {needs a box 3 by 3 minimum}
  397.       TY2 := (Y2 - Y1) div 2 + Y1 + 2;
  398.       TY1 := TY2 - 3;
  399.       if (X2-X1) < 3 then
  400.       begin
  401.          TX2 := X2;
  402.          TX1 := X1;
  403.       end;
  404.       if (Y2-Y1) < 3 then
  405.       begin
  406.          TY2 := Y2;
  407.          TY1 := Y1;
  408.       end;
  409.       repeat
  410.          Screen.PartClear(TX1,TY1,TX2,TY2,vBodyAttr,' ');
  411.          if TX1 >= X1 + (1*Ratio) then 
  412.             TX1 := TX1 - (1*Ratio) 
  413.          else 
  414.             TX1 := X1;
  415.          if TY1 > Y1  then 
  416.             TY1 := TY1 - 1;
  417.          if TX2 + (1*Ratio) <= X2 then 
  418.             TX2 := TX2 + (1*Ratio) 
  419.          else 
  420.             TX2 := X2;
  421.          if TY2 + 1 <= Y2 then 
  422.             TY2 := TY2 + 1;
  423.          delay(10);
  424.       Until (TX1 = X1) and (TY1 = Y1) and (TX2 = X2) and (TY2 = Y2);
  425.       DrawCore;
  426.    end;
  427.    ShadowTOT^.DrawShadow(vBorder);
  428.    SetWindow;
  429.    if not vMVisible then
  430.       Mouse.Show;
  431. end; {WinOBJ.GrowDraw}
  432.  
  433. procedure WinOBJ.PartSave(X1,Y1,X2,Y2:byte; var Dest);
  434. {}
  435. var
  436.    I,w : byte;
  437.    Wid : word;
  438.    ScreenAdr: integer;
  439.    Pntr: pointer;
  440.    Mvisible: boolean;
  441. begin
  442.    w := succ(X2- X1);
  443.    Pntr := Screen.ScreenPtr;
  444.    Mvisible := Mouse.Visible;
  445.    Wid := Monitor^.Width*2;
  446.    if MVisible then
  447.       Mouse.Hide;
  448.    for I :=  Y1 to Y2 do
  449.    begin
  450.       ScreenAdr := Pred(I)*Wid + Pred(X1)*2;
  451.       Screen.MoveFromScreen(Mem[seg(Pntr^):ofs(Pntr^)+ScreenAdr],
  452.                         Mem[seg(Dest):ofs(dest)+(I-Y1)*w*2],
  453.                         w);
  454.    end;
  455.    if MVisible then
  456.       Mouse.Show;
  457. end; {WinOBJ.PartSave}
  458.  
  459. procedure WinOBJ.PartRestore(X1,Y1,X2,Y2:byte; var Source);
  460. {}
  461. var
  462.    I,w : byte;
  463.    Wid: word;
  464.    ScreenAdr: integer;
  465.    Pntr: pointer;
  466.    Mvisible: boolean;
  467. begin
  468.    w := succ(X2- X1);
  469.    Pntr := Screen.ScreenPtr;
  470.    Wid := Monitor^.Width*2;
  471.    MVisible := Mouse.Visible;
  472.    if MVisible then
  473.       Mouse.Hide;
  474.    for I :=  Y1 to Y2 do
  475.    begin
  476.       ScreenAdr := Pred(I)*Wid + Pred(X1)*2;
  477.       Screen.MoveToScreen(Mem[seg(Source):ofs(Source)+(I-Y1)*w*2],
  478.                       Mem[seg(Pntr^):ofs(Pntr^)+ScreenAdr],
  479.                       w);
  480.    end;
  481.    if MVisible then
  482.       Mouse.Show;
  483. end; {WinOBJ.PartRestore}
  484.  
  485. procedure WinOBJ.Remove;
  486. {}
  487. begin
  488.    if vUnderneathPtr <> Nil then
  489.    begin
  490.       Mouse.Hide;
  491.       PartRestore(vOuter.X1,vOuter.Y1,vOuter.X2,vOuter.Y2,vUnderneathPtr^);
  492.       freemem(vUnderneathPtr,vSavedSize);
  493.       vUnderneathPtr := nil;
  494.       if vOldWinConfine then
  495.          with vOldWin do
  496.             Screen.SetWindow(X1,Y1,X2,Y2)
  497.       else
  498.          Screen.ResetWindow;
  499.       Screen.GotoXY(vCursX,vCursY);
  500.       Screen.CursSize(vCursTop,vCursBot);
  501.       if vMVisible then
  502.          Mouse.Show;
  503.    end;
  504. end; {WinOBJ.Remove}
  505.  
  506. procedure WinOBJ.WinGetKey(var K:word;var X,Y:byte);
  507. {}
  508. begin
  509.    with key do
  510.    begin
  511.       Key.GetInput;
  512.       K := Key.LastKey;
  513.       X := Key.LastX;
  514.       Y := Key.LastY;
  515.       WinKey(K,X,Y);
  516.    end;
  517. end; {WinOBJ.WinGetKey}
  518.  
  519. procedure WinOBJ.WinKey(var K:word;var X,Y:byte);      
  520. {}
  521. begin 
  522.    if  (K = 513) and (Y = vBorder.Y1) 
  523.    and (X = vBorder.X1 + 3) and vClose then
  524.    begin
  525.          Remove;
  526.          K := 600;  {Closed}
  527.    end;
  528. end; {WinOBJ.WinKey}
  529.  
  530. destructor WinOBJ.Done;
  531. {}
  532. begin
  533.     if (vRemove) and (vUnderneathPtr <> Nil)  then
  534.        Remove;
  535.     if vUnderneathPtr <> Nil then
  536.        freemem(vUnderneathPtr,vSavedSize);
  537. end; {WinOBJ.Done}
  538. {||||||||||||||||||||||||||||||||||||||||||||}
  539. {                                            }
  540. {    M o v e W i n O B J   M E T H O D S     }
  541. {                                            }
  542. {||||||||||||||||||||||||||||||||||||||||||||}
  543. constructor MoveWinOBJ.Init;
  544. {}
  545. begin
  546.    WinOBJ.Init;
  547.    vAllowMove := true;
  548.    vMoveKey := LookTOT^.WinMoveKey;
  549.    SetBoundary(1,1,Monitor^.Width,Monitor^.Depth);
  550. end; {MoveWinOBJ.Init}
  551.  
  552. procedure MoveWinOBJ.SetMoveKey(K:word);
  553. {}
  554. begin
  555.  
  556. end; {MoveWinOBJ.SetMoveKey}
  557.  
  558. procedure MoveWinOBJ.SetBoundary(X1,Y1,X2,Y2:byte);
  559. {}
  560. begin
  561.    vBoundary.X1 := X1;
  562.    vBoundary.Y1 := Y1;
  563.    vBoundary.X2 := X2;
  564.    vBoundary.Y2 := Y2;
  565. end; {MoveWinOBJ.SetBoundary}
  566.  
  567. procedure MoveWinOBJ.BuildBackground(var BackScr: ScreenOBJ);
  568. {saves the screen and replaces the contents of the screen
  569.  where the window lies with the image saved behind the window.
  570. }
  571. var
  572.    I,w : byte;
  573.    Wid : word;
  574.    ImageAdr: integer;
  575.    Pntr: pointer;
  576. begin
  577.    BackScr.Save;    {save current screen}
  578.    w := succ(vOuter.X2- vOuter.X1);
  579.    Pntr := BackScr.ScreenPtr;
  580.    Wid := Monitor^.Width*2;
  581.    for I :=  vOuter.Y1 to vOuter.Y2 do
  582.    begin
  583.       ImageAdr := Pred(I)*Wid + Pred(vOuter.X1)*2;
  584.       Move(Mem[seg(vUnderneathPtr^):ofs(vUnderneathPtr^)+(I-vOuter.Y1)*w*2],
  585.            Mem[seg(Pntr^):ofs(Pntr^)+ImageAdr],
  586.            w*2);
  587.    end;
  588. end; {MoveWinOBJ.BuildBackground}
  589.  
  590. procedure MoveWinOBJ.RefreshUnderneath(BackScr: ScreenOBJ);
  591. {Takes image from saved screen and moves it to the window's saved
  592.  image at UnderneathPtr.
  593. }
  594. var
  595.    I,w : byte;
  596.    Wid : word;
  597.    ImageAdr: integer;
  598.    Pntr: pointer;
  599. begin
  600.    {dispose of window memory, and get required memory}
  601.    freemem(vUnderneathPtr,vSavedSize);
  602.    w := succ(vOuter.X2- vOuter.X1);
  603.    vSavedSize := succ(vOuter.Y2 - vOuter.Y1)*W*2;
  604.    getmem(vUnderneathPtr,vSavedSize);
  605.    Pntr := BackScr.ScreenPtr;
  606.    Wid := Monitor^.Width*2;
  607.    for I :=  vOuter.Y1 to vOuter.Y2 do
  608.    begin
  609.       ImageAdr := Pred(I)*Wid + Pred(vOuter.X1)*2;
  610.       Move(Mem[seg(Pntr^):ofs(Pntr^)+ImageAdr],
  611.            Mem[seg(vUnderneathPtr^):ofs(vUnderneathPtr^)+(I-vOuter.Y1)*w*2],
  612.            w*2);
  613.    end;
  614. end; {MoveWinOBJ.RefreshUnderneath}
  615.  
  616. procedure MoveWinOBJ.RemoveShadow(var OriginalScreen: ScreenOBJ);
  617. {}
  618. begin
  619.    if vOuter.X1 < vBorder.X1 then   {shadowleft}
  620.       OriginalScreen.PartDisplay(vOuter.X1,vOuter.Y1,pred(vBorder.X1),vOuter.Y2,vOuter.X1,vOuter.Y1);
  621.    if vOuter.X2 > vBorder.X2 then   {shadowright}
  622.       OriginalScreen.PartDisplay(succ(vBorder.X2),vOuter.Y1,vOuter.X2,vOuter.Y2,succ(vBorder.X2),vOuter.Y1);
  623.    if vOuter.Y1 < vBorder.Y1 then   {shadowUp}
  624.       OriginalScreen.PartDisplay(vOuter.X1,vOuter.Y1,vOuter.X2,pred(vBorder.Y1),vOuter.X1,vOuter.Y1);
  625.    if vOuter.Y2 > vBorder.Y2 then  {shadowDown}
  626.       OriginalScreen.PartDisplay(vOuter.X1,succ(vBorder.Y2),vOuter.X2,vOuter.Y2,vOuter.X1,succ(vBorder.Y2));
  627. end; {MoveWinOBJ.RemoveShadow}
  628.  
  629. procedure MoveWinOBJ.WMove(UsingMouse:boolean;OldX,OldY:byte);
  630. var
  631.    Mvisible,
  632.    WasOn,
  633.    Left,Center,Right : boolean;
  634.    X,Y : Byte;
  635.    DeltaX, DeltaY : shortint;
  636.    ScrPtr,
  637.    OldPtr,
  638.    SmartWinImagePtr : pointer;
  639.    Wid: word;
  640.    CTop,CBot,CX,CY:byte;
  641.    W,D: byte;
  642.    OldLocation : tCoords;
  643.    OriginalScreen: ScreenOBJ;
  644.  
  645.   procedure CaptureSmartWin;
  646.   {saves image of window}
  647.   var I : integer;
  648.   begin
  649.      with vBorder do
  650.      begin
  651.         getmem(SmartWinImagePtr,W*D*2);
  652.         Screen.PartSave(X1,Y1,X2,Y2,SmartWinImagePtr^);
  653.      end;
  654.   end; {CaptureSmartWin}
  655.  
  656.   procedure RestoreSmartWin;
  657.   {}
  658.   begin
  659.      with vBorder do
  660.         Screen.PartRestore(X1,Y1,X2,Y2,SmartWinImagePtr^);
  661.   end; {RestoreSmartWin}
  662.  
  663.   procedure DisposeSmartWin;
  664.   {}
  665.   begin
  666.      freemem(SmartWinImagePtr,W*D*2);
  667.   end; {DisposeSmartWin}
  668.  
  669.   procedure FastRestore(X1,Y1,X2,Y2:byte);
  670.   {}
  671.   var
  672.      I,w : byte;
  673.      ScreenAdr: integer;
  674.    begin
  675.       if (X1 > X2) or (Y1 > Y2) then
  676.          exit;
  677.       w := succ(X2 - X1);
  678.       for I :=  Y1 to Y2 do
  679.       begin
  680.          ScreenAdr := Pred(I)*Wid + Pred(X1)*2;
  681.          Screen.MoveToScreen(Mem[seg(OldPtr^):ofs(OldPtr^)+ScreenAdr],
  682.                              Mem[seg(ScrPtr^):ofs(ScrPtr^)+ScreenAdr],
  683.                               w);
  684.       end;
  685.    end; {FastRestore}
  686.  
  687. begin
  688.    with vBorder do
  689.    begin
  690.       W := succ(X2 - X1);
  691.       D := succ(Y2 - Y1);
  692.    end;
  693.    if MaxAvail < W*D*2 * Screen.Width*Screen.Depth*2 then
  694.    begin
  695.       Beep;
  696.       Exit;
  697.    end;
  698.    with Screen do
  699.    begin
  700.       CursSave;
  701.       CX := Screen.WhereX;
  702.       CY := Screen.WhereY;
  703.       CTop := CursTop;
  704.       CBot := CursBot;
  705.       CursOff;
  706.    end;
  707.    OriginalScreen.Init;
  708.    MVisible := Mouse.Visible;
  709.    if MVisible then
  710.       Mouse.Hide;
  711.    BuildBackground(OriginalScreen);
  712.    ScrPtr :=  ptr(Monitor^.vBaseOfScreen,0);
  713.    OldPtr := OriginalScreen.ScreenPtr;
  714.    Wid := Monitor^.Width*2;
  715.    CaptureSmartWin;
  716.    RemoveShadow(OriginalScreen);
  717.    repeat
  718.       if UsingMouse then
  719.       begin
  720.          Mouse.Show;
  721.          Mouse.Status(Left,Center,Right,X,Y);
  722.       end
  723.       else
  724.       begin
  725.          with Key do
  726.          begin
  727.             OldX := 20;
  728.             OldY := 20;
  729.             Y := 20;
  730.             X := 20;
  731.             GetInput;
  732.             Case Key.LastKey of
  733.                328: dec(Y); {up}
  734.                336: inc(Y); {down}
  735.                333: inc(X); {right}
  736.                331: dec(X); {left}
  737.             end; {case}
  738.             Left := true;
  739.          end;
  740.       end;
  741.       if Left and ( (X <> OldX) or (Y <> OldY) ) then  {move window}
  742.       begin
  743.          OldLocation := vOuter;
  744.          if (X <> OldX) then
  745.          begin
  746.             DeltaX := X - OldX;
  747.             if  (DeltaX + vBorder.X1 >= vBoundary.X1)
  748.             and (DeltaX + vBorder.X2 <= vBoundary.X2) then
  749.             begin
  750.                vBorder.X1 := vBorder.X1 + DeltaX;
  751.                vBorder.X2 := vBorder.X2 + DeltaX;
  752.             end
  753.             else DeltaX := 0;
  754.          end
  755.          else
  756.             DeltaX := 0;
  757.          if (Y <> OldY) then
  758.          begin
  759.             DeltaY := Y - OldY;
  760.             if  (DeltaY + vBorder.Y1 >= vBoundary.Y1)
  761.             and (DeltaY + vBorder.Y2 <= vBoundary.Y2) then
  762.             begin
  763.                vBorder.Y1 := vBorder.Y1 + DeltaY;
  764.                vBorder.Y2 := vBorder.Y2 + DeltaY;
  765.             end
  766.             else
  767.               DeltaY := 0;
  768.          end
  769.          else
  770.             DeltaY := 0;
  771.          ComputeSavedCoords;
  772.          Mouse.Hide;
  773.          RestoreSmartWin;
  774.          if DeltaX > 0 then {viewport moved right}
  775.             FastRestore(OldLocation.X1,vOuter.Y1,pred(vBorder.X1),vOuter.Y2)
  776.          else if DeltaX < 0 then {viewport moved left}
  777.             FastRestore(succ(vBorder.X2),vBorder.Y1,OldLocation.X2,vOuter.Y2);
  778.          if DeltaY > 0 then {Viewport moved down}
  779.             FastRestore(OldLocation.X1,OldLocation.Y1,vBorder.X2,pred(vBorder.Y1))
  780.          else if deltaY < 0 then {Viewport moved up}
  781.             FastRestore(OldLocation.X1,succ(vBorder.Y2),vBorder.X2,OldLocation.Y2);
  782.          if DeltaX < 0 then    {moved left}
  783.          begin
  784.              if (DeltaY > 0) then
  785.                 FastRestore(succ(vBorder.X1),OldLocation.Y1,Oldlocation.X2,pred(vBorder.Y1))
  786.              else
  787.                 FastRestore(succ(vBorder.X2),succ(vOuter.Y2),Oldlocation.X2,OldLocation.Y2);
  788.          end;
  789.          OldX := X;
  790.          OldY := Y;
  791.          {Mouse.Move(X,Y);}
  792.       end; {if}
  793.    until (UsingMouse and (Left = false)) or (((Key.LastKey =13) or (Key.LastKey =27)) and (UsingMouse = false));
  794.    Mouse.Hide;
  795.    WasOn := Screen.WindowOff;
  796.    ShadowTOT^.DrawShadow(vBorder);
  797.    Screen.WindowOn;
  798.    if MVisible then
  799.       Mouse.Show;
  800.    {now save new background behind window}
  801.    RefreshUnderneath(OriginalScreen);
  802.    SetWindow;
  803.    Screen.GotoXY(CX,CY);
  804.    Screen.CursSize(CTop,CBot);
  805.    OriginalScreen.Done;
  806.    DisposeSmartWin;
  807. end; {MoveWinOBJ.Move}
  808.  
  809. procedure MoveWinOBJ.SetAllowMove(On:boolean);
  810. {}
  811. begin
  812.    vAllowMove := On;
  813. end; {MoveWinOBJ.SetAllowMove}
  814.  
  815. procedure MoveWinOBJ.WinKey(var K:word;var X,Y:byte);
  816. {}
  817. begin
  818.    if (K = vMoveKey) and (vAllowMove) then
  819.       WMove(false,X,Y)
  820.    else if  (K = 513) and (Y = vBorder.Y1) and
  821.    (X >= vBorder.X1) and (X <= vBorder.X2) then
  822.    begin
  823.       if (X = vBorder.X1 + 3) and vClose then
  824.       begin
  825.          Remove;
  826.          K := 600;  {Closed}
  827.       end
  828.       else if vAllowMove then
  829.       begin
  830.          WMove(true,X,Y);
  831.          K := 601;  {Moved}
  832.       end;
  833.    end;
  834. end; {MoveWinOBJ.WinKey}
  835.  
  836. destructor MoveWinOBJ.Done;
  837. {}
  838. begin
  839.    WinOBJ.Done;
  840. end; {MoveWinOBJ.Done}
  841. {||||||||||||||||||||||||||||||||||||||||||||||||}
  842. {                                                }
  843. {    S c r o l l W i n O B J   M E T H O D S     }
  844. {                                                }
  845. {||||||||||||||||||||||||||||||||||||||||||||||||}
  846. constructor ScrollWinOBJ.Init;
  847. {}
  848. begin
  849.    MoveWinOBJ.Init;
  850.    vScrollV := false;
  851.    vScrollH := false;
  852. end; {ScrollWinOBJ.Init}
  853.  
  854. procedure ScrollWinOBJ.SetScrollable(Vert,Horiz:boolean);
  855. {}
  856. begin
  857.    vScrollV := Vert;
  858.    vScrollH := Horiz;
  859. end; {ScrollWinOBJ.SetScrollable}
  860.  
  861. procedure ScrollWinOBJ.DrawHorizBar(Current,Max: longint);
  862. {}
  863. var
  864.   WasOn: boolean;
  865.   CursX,CursY : byte;
  866. begin
  867.    if (vStyle in [1..5]) and (vScrollH) then
  868.    begin
  869.       CursX := Screen.WhereX;
  870.       CursY := Screen.WhereY;
  871.       WasOn := Screen.WindowOff;
  872.       with vBorder do
  873.          Screen.WriteHScrollBar(succ(X1),pred(X2),Y2,vBorderAttr,Current,Max);
  874.       SetWindow;
  875.       Screen.GotoXY(CursX,CursY);
  876.    end; 
  877. end; {ScrollWinOBJ.DrawHorizBar}
  878.  
  879. procedure ScrollWinOBJ.DrawVertBar(Current,Max: longint);
  880. {}
  881. var
  882.    WasOn: boolean;
  883.    CursX,CursY : byte;
  884. begin
  885.    if (vStyle in [1..5]) and (vScrollV) then
  886.    begin
  887.       CursX := Screen.WhereX;
  888.       CursY := Screen.WhereY;
  889.       WasOn := Screen.WindowOff;
  890.       with vBorder do
  891.          Screen.WriteVScrollBar(X2,succ(Y1),pred(Y2),vBorderAttr,Current,Max);
  892.       SetWindow;
  893.       Screen.GotoXY(CursX,CursY);
  894.    end;
  895. end; {ScrollWinOBJ.DrawVertBar}
  896.  
  897. procedure ScrollWinOBJ.WinKey(var K:word;var X,Y:byte);
  898. { RetCodes
  899. 610 = Scroll Up One
  900. 611 = Scroll Down One
  901. 612 = Scroll Left one
  902. 613 = Scroll Right one
  903. 614 = Vertical Scroll Bar
  904. 615 = Horizontal Scroll Bar
  905. }
  906. begin
  907.    if K = vMoveKey then
  908.       WMove(false,X,Y)
  909.    else if  (K = 513) then
  910.    begin
  911.       if (Y = vBorder.Y1) and
  912.       (X >= vBorder.X1) and (X <= vBorder.X2) then
  913.       begin
  914.          if (X = vBorder.X1 + 3) and vClose then
  915.          begin
  916.             Remove;
  917.             K := 600;  {Closed}
  918.          end
  919.          else
  920.          begin
  921.             WMove(true,X,Y);
  922.             K := 601;  {Moved}
  923.          end;
  924.       end
  925.       else if vScrollV and (X = vBorder.X2) then
  926.       begin
  927.           if  Y = succ(vBorder.Y1) then
  928.              K := 610
  929.           else if Y =  pred(vBorder.Y2)  then
  930.              K := 611
  931.           else if  (Y > succ(vBorder.Y1))
  932.              and (Y < pred(vBorder.Y2)) then {scroll bar}
  933.              begin
  934.                 {adjust X to represent no of characters down scroll bar}
  935.                 {adjust Y to return total length of scroll bar}
  936.                 K := 614;
  937.                 X := Y - succ(vBorder.Y1);
  938.                 Y := vBorder.Y2 - vBorder.Y1 - 3;
  939.              end;
  940.       end
  941.       else  if vScrollH and (Y = vBorder.Y2) then
  942.       begin
  943.          if X = succ(vBorder.X1) then
  944.             K := 612
  945.          else if X = pred(vBorder.X2) then
  946.             K := 613
  947.          else if  (X > succ(vBorder.X1))
  948.             and (X < pred(vBorder.X2)) then
  949.             begin
  950.                K := 615;
  951.                X := X - succ(vBorder.X1);
  952.                Y := vBorder.X2 - vBorder.X1 - 3;
  953.             end;
  954.       end;
  955.    end;
  956. end; {ScrollWinOBJ.WinKey}
  957.  
  958. procedure ScrollWinOBJ.Draw;
  959. {}
  960. begin
  961.    if not (vStyle in [1..5]) then
  962.       vStyle := 1;
  963.    MoveWinOBJ.Draw;
  964. end; {ScrollWinOBJ.Draw}
  965.  
  966. destructor ScrollWinOBJ.Done;
  967. {}
  968. begin
  969.    MoveWinOBJ.Done;
  970. end; {ScrollWinOBJ.Done}
  971. {||||||||||||||||||||||||||||||||||||||||||||||||||}
  972. {                                                  }
  973. {    S t r e t c h W i n O B J   M E T H O D S     }
  974. {                                                  }
  975. {||||||||||||||||||||||||||||||||||||||||||||||||||}
  976. constructor StretchWinOBJ.Init;
  977. {}
  978. begin
  979.    ScrollWinOBJ.Init;
  980.    vZoomed := false;
  981.    vPreZoom := vBorder;
  982.    vMinWidth := 10;
  983.    vMinDepth := 5;
  984.    vStretchKey:= LookTOT^.vWinStretchKey;
  985.    vZoomKey:= LookTOT^.vWinZoomKey;
  986.    vAllowStretch := true;
  987.    vSmartStretch := false;
  988. end; {StretchWinOBJ.Init}
  989.  
  990. procedure StretchWinOBJ.SetAllowStretch(On:boolean);
  991. {}
  992. begin
  993.    vAllowStretch := On;
  994. end; {StretchWinOBJ.SetAllowStretch}
  995.  
  996. procedure StretchWinOBJ.SetMinSize(Width,depth:byte);
  997. {}
  998. begin
  999.    vMinWidth := width;
  1000.    vMinDepth := depth;
  1001. end; {StretchWinOBJ.SetMinSize}
  1002.  
  1003. procedure StretchWinOBJ.ToggleZoom;
  1004. {zooms or unzooms a window}
  1005. begin
  1006.    vZoomed := not vZoomed;
  1007.    Remove;             {remove the window}
  1008.    if vUnderneathPtr <> Nil then
  1009.       FreeMem(vUnderneathPtr,succ(vOuter.X2-vOuter.X1)*succ(vOuter.Y2-vOuter.Y1)*2);
  1010.    if not vZoomed then
  1011.       vBorder := vPreZoom  {set zone coords back to the old coords}
  1012.    else
  1013.    begin
  1014.       vPreZoom := vBorder;  {save the un-zoomed coordinates}
  1015.       vBorder := vBoundary; {set window coords to the maximum}
  1016.    end;      
  1017.    ComputeSavedCoords;
  1018.    Draw;        
  1019. end; {StretchWinOBJ.ToggleZoom}
  1020.  
  1021. procedure StretchWinOBJ.StretchRefresh;
  1022. {abstract} begin end;
  1023.  
  1024. procedure StretchWinOBJ.Stretch(UsingMouse:boolean;OldX,OldY:byte);
  1025. {}
  1026. const
  1027.    BorderChar = '█';
  1028.    Col = white;
  1029. var
  1030.    Mvisible,
  1031.    WasOn: boolean;
  1032.    Left,Center,Right : boolean;
  1033.    CTop,CBot,CX,CY:byte;
  1034.    NewX,NewY,
  1035.    X,Y : Byte;
  1036.    OriginalScreen: ScreenOBJ;
  1037.    BackScreen: ScreenOBJ;
  1038.  
  1039.      procedure ChangePerimeter;
  1040.      {}
  1041.      var
  1042.        I : integer;
  1043.      begin
  1044.         if NewX <> vBorder.X2 then
  1045.         with vBorder do
  1046.         begin
  1047.            OriginalScreen.PartDisplay(X2,Y1,X2,Y2,X2,Y1);
  1048.            if NewX < X2 then
  1049.            begin
  1050.               OriginalScreen.PartDisplay(succ(NewX),Y1,X2,Y2,succ(NewX),Y1);
  1051.               OriginalScreen.PartDisplay(succ(NewX),Y2,X2,Y2,succ(NewX),Y2);
  1052.            end;
  1053.         end;
  1054.         if NewY <> vBorder.Y2 then
  1055.         with vBorder do
  1056.         begin
  1057.            OriginalScreen.PartDisplay(X1,Y2,X2,Y2,X1,Y2);
  1058.            if NewY < Y2 then
  1059.            begin
  1060.               OriginalScreen.PartDisplay(X1,succ(NewY),X2,Y2,X1,succ(NewY));
  1061.               OriginalScreen.PartDisplay(X2,succ(NewY),X2,Y2,X2,succ(NewY));
  1062.            end;
  1063.         end;
  1064.         {draw new perimiter}
  1065.         with vBorder do
  1066.         begin
  1067.            X2 := NewX;
  1068.            Y2 := NewY;
  1069.            Screen.Box(X1,Y1,X2,Y2,white,ord(BorderChar));
  1070.         end;
  1071.      end;
  1072. begin
  1073.    if MaxAvail < 4*Screen.Width*Screen.Depth then
  1074.    begin
  1075.       Beep;
  1076.       exit;
  1077.    end;
  1078.    WasOn := Screen.WindowOff;
  1079.    OriginalScreen.Init;
  1080.    MVisible := Mouse.Visible;
  1081.    if MVisible then
  1082.       Mouse.Hide;
  1083.    OriginalScreen.Save;
  1084.    BackScreen.Init;
  1085.    BuildBackground(BackScreen);
  1086.    if vSmartStretch then
  1087.       with OriginalScreen do
  1088.          move(Backscreen.ScreenPtr^,ScreenPtr^,Depth*Width*2);
  1089.    if vUnderneathPtr <> Nil then
  1090.    begin
  1091.        FreeMem(vUnderneathPtr,vSavedSize);
  1092.        vUnderneathPtr := Nil;
  1093.    end;
  1094.    with vBorder do
  1095.    begin
  1096.       Screen.Box(X1,Y1,X2,Y2,col,ord(BorderChar));
  1097.       OldX := X2;
  1098.       OldY := Y2;
  1099.    end;
  1100.    RemoveShadow(OriginalScreen);
  1101.    with Screen do
  1102.    begin
  1103.       CursSave;
  1104.       CX := Screen.WhereX;
  1105.       CY := Screen.WhereY;
  1106.       CTop := CursTop;
  1107.       CBot := CursBot;
  1108.       CursOff;
  1109.    end;
  1110.    Repeat
  1111.       if UsingMouse then
  1112.       begin
  1113.          Mouse.Show;
  1114.          Mouse.Status(Left,Center,Right,X,Y);
  1115.       end
  1116.       else
  1117.       begin
  1118.          with Key do
  1119.          begin
  1120.             OldX := vBorder.X2;
  1121.             OldY := vBorder.Y2;
  1122.             Y := OldY;
  1123.             X := OldX;
  1124.             GetInput;
  1125.             Case Key.LastKey of
  1126.                328: dec(Y); {up}
  1127.                336: inc(Y); {down}
  1128.                333: inc(X); {right}
  1129.                331: dec(X); {left}
  1130.             end; {case}
  1131.             (*
  1132.             X := OldX;
  1133.             Y := OldY;
  1134.             GetInput;
  1135.             Case Key.LastKey of
  1136.                328: if Y > 1 then
  1137.                       dec(Y); {up}
  1138.                336: if Y < 100 then
  1139.                        inc(Y); {down}
  1140.                333: if X < 100 then
  1141.                        inc(X); {right}
  1142.                331: if X > 1 then
  1143.                        dec(X); {left}
  1144.             end; {case}
  1145.             *)
  1146.          end;
  1147.          Left := true;
  1148.       end;
  1149.       if Left and ( (X <> OldX) or (Y <> OldY) ) then  {stretch window}
  1150.       begin
  1151.          if (succ(X - vBorder.X1 ) < vMinWidth) then  {too small}
  1152.             NewX := pred(vBorder.X1 + vMinWidth)
  1153.          else
  1154.          if (X > vBoundary.X2) then                 {out of bounds}
  1155.             NewX := vBoundary.X2
  1156.          else
  1157.             NewX := X;
  1158.          if (succ(Y - vBorder.Y1 ) < vMinDepth) then  {too small}
  1159.             NewY := pred(vBorder.Y1 + vMinDepth)
  1160.          else
  1161.          if (Y > vBoundary.Y2) then                 {out of bounds}
  1162.             NewY := vBoundary.Y2
  1163.          else
  1164.             NewY := Y;
  1165.          ChangePerimeter;
  1166.          if vSmartStretch then
  1167.             StretchRefresh;
  1168.          OldX := NewX;
  1169.          OldY := NewY;
  1170.       end; {if}
  1171.    until (UsingMouse and (Left = false)) or (((Key.LastKey =13) or (Key.LastKey = 27)) and (UsingMouse = false));
  1172.    ComputeSavedCoords;
  1173.    { draw the new image }
  1174.    BackScreen.Display;
  1175.    OriginalScreen.Done;
  1176.    BackScreen.Done;
  1177.    vZoomed := (vBorder.X1 = vBoundary.X1)
  1178.                and (vBorder.Y1 = vBoundary.Y1)
  1179.                and (vBorder.X2 = vBoundary.X2)
  1180.                and (vBorder.Y2 = vBoundary.Y2);
  1181.    SetWindow;
  1182.    Draw;
  1183.    Screen.GotoXY(CX,CY);
  1184.    Screen.CursSize(CTop,CBot);
  1185.    if MVisible then
  1186.       Mouse.Show;
  1187. end; {StretchWinOBJ.Stretch}
  1188.  
  1189. procedure StretchWinOBJ.Winkey(var K:word;var X,Y:byte);
  1190. {}
  1191. begin
  1192.    if (K = vStretchKey) and vAllowStretch then
  1193.    begin
  1194.       Stretch(false,X,Y);
  1195.       K := 602;
  1196.    end
  1197.    else if (K = 513) and (X = vBorder.X2) and (Y = vBorder.Y2) and vAllowStretch then
  1198.    begin
  1199.       Stretch(true,X,Y);
  1200.       K := 602;
  1201.    end
  1202.    else if (((K = 513) and (X = vBorder.X2 - 3) and (Y = vBorder.Y1))
  1203.         or (K = vZoomKey)) and vAllowStretch then
  1204.    begin
  1205.       ToggleZoom;
  1206.       K := 602;
  1207.    end
  1208.    else
  1209.       ScrollWinOBJ.WinKey(K,X,Y);
  1210. end; {StretchWinOBJ.Winkey}
  1211.  
  1212. procedure StretchWinOBJ.Refresh;
  1213. {}
  1214. var WasOn: boolean;
  1215. begin
  1216.    WasOn := Screen.WindowOff;
  1217.    ShadowTOT^.DrawShadow(vBorder);
  1218.    if vClose then
  1219.    begin
  1220.       with vBorder do
  1221.       begin
  1222.          Screen.BoxEngine(X1,Y1,X2,Y2,4,4,vBorderAttr,vTitleAttr,vBodyAttr,vStyle,true,vTitle);
  1223.          Screen.WriteAT(X1+2,Y1,vBorderAttr,'[ ]');
  1224.          Screen.WriteAT(X1+3,Y1,vIconsAttr,'■');
  1225.       end;
  1226.    end
  1227.    else
  1228.       with vBorder do
  1229.          Screen.BoxEngine(X1,Y1,X2,Y2,0,4,vBorderAttr,vTitleAttr,vBodyAttr,vStyle,true,vTitle);
  1230.    if vAllowStretch then
  1231.    begin
  1232.       Screen.WriteAT(vBorder.X2-4,vBorder.Y1,vBorderAttr,'[ ]');
  1233.       if not vZoomed then
  1234.          Screen.WriteAT(vBorder.X2-3,vBorder.Y1,vIconsAttr,'')
  1235.       else
  1236.          Screen.WriteAT(vBorder.X2-3,vBorder.Y1,vIconsAttr,'');
  1237.    end;
  1238.    SetWindow;
  1239. end; {StretchWinOBJ.Refresh}
  1240.  
  1241. procedure StretchWinOBJ.Draw;
  1242. {}
  1243. begin
  1244.    if not (vStyle in [1..5]) then
  1245.       vStyle := 1;
  1246.    Save;
  1247.    vMVisible := Mouse.Visible;
  1248.    Refresh;
  1249.    if not vMVisible then
  1250.       Mouse.Show;
  1251. end; {StretchWinOBJ.Draw}
  1252.  
  1253. destructor StretchWinOBJ.Done;
  1254. {}
  1255. begin
  1256.    ScrollWinOBJ.Done;
  1257. end; {StretchWinOBJ.Done}
  1258. {|||||||||||||||||||||||||||||||||||||||||||||||}
  1259. {                                               }
  1260. {     U N I T   I N I T I A L I Z A T I O N     }
  1261. {                                               }
  1262. {|||||||||||||||||||||||||||||||||||||||||||||||}
  1263. procedure WinInit;
  1264. {initilizes objects and global variables}
  1265. begin
  1266. end;
  1267.  
  1268. {end of unit - add intialization routines below}
  1269. {$IFNDEF OVERLAY}
  1270. begin
  1271.    WinInit;
  1272. {$ENDIF}
  1273. end.
  1274.